program TurnList2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
type
  pelement = ^element;
  element = record
    value : Integer;
    next : pelement;
  end;


procedure ATB (var head : pelement; num : integer);
var
  tmp : pelement;
begin
  tmp := head;
  New (head);
  head^.value := num;
  head^.next := tmp;
end;

procedure ATE (var head : pelement; num : integer);
var
  current : pelement;
begin
  if (head<>nil) then
  begin
    current := head;
  while(current^.next<>nil) do
  begin
    current:=current^.next;
  end;
  new(current^.next);
  current^.next^.value:=num;
  current^.next^.next:=nil;
  end else begin
    ATB(head, num);
  end;
end;

procedure PrintList (head : pelement);
var
  current : pelement;
begin
  current:=head;
  while(current<>nil) do
  begin
    writeln(current^.value);
    current:=current^.next;
  end;
end;

var
  fin : textfile;
  n, i, l, b, a : integer;
  head, head2 : pelement;

begin
assignfile(fin, 'inputTL.txt');
reset(fin);
readln(fin, n);
for i:=0 to n-1 do
begin
  read(fin, a);
  ATB(head, a);
end;


for i := 0 to l-1 do
begin
  ATE(head2, head^.value);
  head := head^.next;
end;

for i := 0 to n-1 do
begin
  if(head<>nil) then
  begin
   ATE(head2, head^.value);
    if(head^.next<>nil) then
    begin
      head:=head^.next;
    end else begin
    break;
    end;
  end;
end;
PrintList(head2);
closefile(fin);
readln;
end.
